package br.com.simora.musica;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="artista")
public class Artista implements Serializable {

	public Long getTotal() {
		return total;
	}

	public void setTotal(Long total) {
		this.total = total;
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = -1302097047937961748L;

	@Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name="id")
    private Integer id;
	
	@Column(name="nome")
	private String nome;
	
	@OneToMany(fetch = FetchType.LAZY, cascade=CascadeType.REMOVE)
	@JoinColumn(name="artista_id")
	private List<ArtistaNomeSinonimo> sinonimos;
	
	@OneToMany(fetch = FetchType.LAZY, cascade=CascadeType.REMOVE)
	@JoinColumn(name="artista_id")
	private List<Musica> musicas;
	
	private transient Long total;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		if(null != nome && !"".equals(nome)){
			this.nome = nome.toLowerCase();
		}
	}

	public List<ArtistaNomeSinonimo> getSinonimos() {
		return sinonimos;
	}

	public void setSinonimos(List<ArtistaNomeSinonimo> sinonimos) {
		this.sinonimos = sinonimos;
	}

	public List<Musica> getMusicas() {
		return musicas;
	}

	public void setMusicas(List<Musica> musicas) {
		this.musicas = musicas;
	}
	
}